/*
 *  linux/mm/memory.c
 *
 *  (C) 1991  Linus Torvalds
 */

/*
 * demand-loading started 01.12.91 - seems it is high on the list of
 * things wanted, and it should be easy to implement. - Linus
 */

/*
 * Ok, demand-loading was easy, shared pages a little bit tricker. Shared
 * pages started 02.12.91, seems to work. - Linus.
 *
 * Tested sharing by executing about 30 /bin/sh: under the old kernel it
 * would have taken more than the 6M I have free, but it worked well as
 * far as I could see.
 *
 * Also corrected some "invalidate()"s - I wasn't doing enough of them.
 */

 /* these are not to be changed without changing head.s etc */
#define LOW_MEM 0x100000
#define PAGING_MEMORY (15*1024*1024)
#define PAGING_PAGES (PAGING_MEMORY>>12)
#define MAP_NR(addr) (((addr)-LOW_MEM)>>12)
#define USED 100

static long HIGH_MEMORY = 0;

static unsigned char mem_map [ PAGING_PAGES ] = {0,};

// lgg : mark mem from (LOW_MEM) 1MB  to 16MB, so PAGING_MEMORY is 15MB
// 1~3MB is USED
// 4MB ~ 16MB is 0  (4MB is the start_mem)
void mem_init(long start_mem, long end_mem)
{
	int i;

	HIGH_MEMORY = end_mem; // 16MB
	for (i=0 ; i<PAGING_PAGES ; i++)  // 3840 times : 15*1024*1024 >>12 = 15*256
		mem_map[i] = USED;
	i = MAP_NR(start_mem); // start_mem : 4MB; i : 768
	end_mem -= start_mem;
	end_mem >>= 12;           
	while (end_mem-->0)     // 3072 : (16-4)*256
		mem_map[i++]=0;    // 

	// after all : i == 3840,  
	//mem_map[0 ~ 768 -1] is USED, 
	//mem_map[768 ~ 3840-1] is 0,  (for Chinese: main memory zone)
}

